package model;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import net.ck.hzq.R;

import java.util.List;

import Bean.Kd100Bean;

public class ListviewLpgisticsinfomationAdapter extends BaseAdapter {

    private List<Kd100Bean.DataBean> data;//数据

    private Context context;//上下文

    public ListviewLpgisticsinfomationAdapter(List<Kd100Bean.DataBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder viewHolder;
        if (convertView == null) {
            view = LayoutInflater.from(context).inflate(R.layout.listviewlogisticsinfomation_item, null, false);
            viewHolder = new ViewHolder();
            viewHolder.textView1 = (TextView) view.findViewById(R.id.listviewlogis_txt1);
            viewHolder.textView2 = (TextView) view.findViewById(R.id.listviewlogis_txt2);
            view.setTag(viewHolder);
        } else {
            view = convertView;
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.textView1.setText(data.get(position).getTime());
        viewHolder.textView2.setText(data.get(position).getContext());

        return view;
    }

    private class ViewHolder {
        TextView textView1, textView2;
    }

}
